package com.mls.fivedistrict.pojo;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.annotations.Version;
import com.baomidou.mybatisplus.enums.IdType;
import com.mls.fivedistrict.enums.GoodsTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * <p>
 * </p>
 *
 * @author Five Team
 * @since 2018-05-16
 */
@Data
@Accessors(chain = true)
@TableName("t_goods")
public class Goods extends Model<Goods> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 分类ID
     */
    private Long classifyId;
    /**
     * 商品标题
     */
    @NotBlank(message = "商品标题不能为空")
    private String title;
    /**
     * 商品介绍
     */
    private String introduce;
    /**
     * 商品类型：0：实体商品 1：代表虚拟商品
     */
    @NotNull(message = "商品类型不能为空")
    private GoodsTypeEnum goodsType;
    /**
     * 商品价格
     */
    @NotNull(message = "商品价格不能为空")
    @Min(value = 0, message = "商品价格不能小于0")
    private BigDecimal price;
    /**
     * 商品库存
     */
    @Min(value = 0, message = "仓库最小库存为0")
    private Integer inventory;
    /**
     * 主图
     */
    private String mainIcon;
    private Date createDate;
    private Date updateDate;
    private String createBy;
    /**
     * 折扣
     */
    @Max(value = 10, message = "折扣不能大于10")
    @Min(value = 0, message = "折扣不能小于0")
    private BigDecimal discount;
    /**
     * 折后价
     */
    @Min(value = 0, message = "折扣价不能小于0")
    private BigDecimal discountPrice;
    /**
     * 参与购买商品人的最小DWQ量
     */
    @NotNull(message = "最小的DWQ量不能为空")
    @Min(value = 0, message = "最小的DWQ量不能为负数")
    private BigDecimal minDwqAbility;
    /**
     * 奖励DWQ数量
     */
    @Min(value = 0,message = "奖励的DWQ量不能为负数")
    private BigDecimal  rewardDwqNumber;
    @TableLogic
    private Boolean isDelete;
    private Boolean isEnable;
    @Version
    private Integer version;

    private transient List<GoodsPayIntegral> goodsPayIntegralList;

    private transient List<GoodsImages> goodsImages;

    private transient Long sellCount;

    public Boolean getDelete() {
        return isDelete;
    }

    public void setDelete(Boolean delete) {
        isDelete = delete;
    }

    public Boolean getEnable() {
        return isEnable;
    }

    public void setEnable(Boolean enable) {
        isEnable = enable;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
